#!/usr/bin/ruby

# AUDIO PROPERTIES
RATE = 8000
OUT_AUD_FORMAT = "ogg"
TMP_AUD_FORMAT = "ogg"
AUD_FORMAT = "ogg"

BLOCK_DUR = 10 # minutes
OVERLAP_DUR = 15 # seconds

SILENCE_DUR = 2.0 # seconds
THRESHOLD = 10 # percent amplitude

# FILES & DIRECTORIES
RAMO_HOME = "/opt/radio-monitor/"

JOIN_RB = RAMO_HOME + "./join_recs.rb"
FORM_RB = RAMO_HOME + "./web/form.rb"
CONFIRM_RB = RAMO_HOME + "./web/confirm.rb"
MK_REC_RB = RAMO_HOME + "./mk-rec.rb"

REC_DIR = '/media/data/recordings/'
DB_FILE  = RAMO_HOME + "./recs.db"

# LOG FILES
DAEMON_LOG = RAMO_HOME + "./log/daemon.log"
WEB_LOG = RAMO_HOME + "./log/web.log"

# DATABASE
FNAME_DB_IDX = 0
START_T_DB_IDX = 1
DUR_DB_IDX = 2
CHAT_LEN_DB_IDX = 3
HAVE_FILE_IDX = 4

# HTML
HTML_HEAD = "
<html>
<head>
<title> Police Scanner Recorder</title>
</head>
<body>
<center>
<h1> Daily Cal Police Scanner Monitor (alpha) </h1>
</center>
"
#<h4> Note: system maintenance in progress; please excuse slow performance </h4>

HTML_END = "
<h4> Note: Alpha means that the system is still under development, so we can
make no performance guarantees.
</body></head>"


def s2hms(x)
    s = pad2(x % 60)
    m = pad2(( x / 60 ) % 60)
    h = x / (60*60)
    return "#{h}:#{m}:#{s}"
end

def pad2(x)
    return pad(x,2)
end

def pad(x, n)
    return "%0#{n}d" % x
end

def assert(x)
    if not x
        return 1/0
    end
end

